package ar.uba.fi.algo3.java2d.ejemplo5;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;

public class MiCustomComponent extends Component {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6895069084519246352L;
	private boolean esRojo;
	
	private Color getColor(){
		if(esRojo){
			esRojo = false;
			return Color.RED;
		}
		else{
			esRojo = true;
			return Color.BLUE;
		}
			
	}
	public MiCustomComponent(){
		this.setSize(70, 70);
	}
	
	@Override
	public void paint(Graphics g){
		g.setColor(getColor());
		int w = (int) Math.round(this.getSize().getWidth());
		int h = (int) Math.round(this.getSize().getHeight());
		g.fillRect(0, 0, w, h);
		System.out.println("painting");
	}
	
}
